<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<link rel="stylesheet" type="text/css" href="js/ChatIndex.css">
<link rel="stylesheet" type="text/css" href="js/showGameChatpost.css">
<link rel="stylesheet" type="text/css" href="js/layui.css">
<link rel="stylesheet" type="text/css" href="js/laypage.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script type="text/javascript" src="js/laypage.js"></script>
<script type="text/javascript" src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<title>用户帖子管理</title>
<script type="text/javascript">
  
  $(function(){
	  $.ajax({
		  url:'getUser.do',
		  type:'post',
		  dataType:'json',
		  success:function(result){
			  vue.user=result
		  }
	  });
	  
	  var vue=new Vue({
		  el:'#userMessage',
		  data:{
			user:"",  
		  },
	  });
	  $.ajax({
		  url:'getLoveGame.do',
		  type:'post',
		  dataType:'json',
		  success:function(result){
			 /*  alert(result); */
			  vu.loveGame=result;
		  }
	  });
	  $("#mylove").click(function(){
		  $("#showReply").css('display','none'); 
		  $("#showMyPost").css('display','none'); 
		  $("#show").show(); 
		  $.ajax({
			  url:'getLoveGame.do',
			  type:'post',
			  dataType:'json',
			  success:function(result){
				 /*  alert(result); */
				  vu.loveGame=result;
			  }
		  })
	  });
	  
	  var vu=new Vue({
		  el:'#show',
		  data:{
			loveGame:"",			
		  },
	  });
	  
	
		  
	 $("#show").delegate("a.noLove","click",function(){
		 var haa=confirm("我觉得还有救，不要放弃我");
		 if(haa){
			 var gameId= $(this).siblings("input").val();
				/* alert(gameId); */
				 $.ajax({
					  url:'notLoveGame.do',
					  type:'post',				  
					  data:{gameId:gameId},				  				  
				  });
				 $(this).parent().parent("tr").remove();
		 }
			
	 })
	 
	$("#myPost").click(function(){
		 $("#showMyPost").show(); 
		  $("#show").css('display','none');
		  $("#showReply").css('display','none'); 
		showPost(1);
	});
	 
	 $("#myReply").click(function(){
		 $("#show").css('display','none'); 
		 $("#showMyPost").css('display','none'); 
		 $("#showReply").show(); 
		 showReply(1);
	 });
	 
	 
	  
  });
 
  function showChatContent(obj){
		 var postId=$(obj).siblings("input").eq(0).val();
		 var postTitle=$(obj).siblings("input").eq(1).val();
		 var postContent=$(obj).siblings("input").eq(2).val();
		 var gameId=$(obj).siblings("input").eq(3).val();
		 var gameName=$(obj).siblings("input").eq(4).val();
		 var uid=$(obj).siblings("input").eq(5).val();
		 var photo=$(obj).siblings("input").eq(6).val();
		 /* alert(postId+" "+postTitle+" "+postContent+" "+gameId+" "+gameName+" "+uid+" "+photo); */
		location.href="chatContent?postId="+postId+"&postTitle="+postTitle+"&postContent="+postContent+"&gameId="+gameId+"&gameName="+gameName+"&uid="+uid+"&photo="+photo;
	 }
  
  function hh(obj){
	  var postId=$(obj).siblings("input").eq(0).val();
		 var postTitle=$(obj).siblings("input").eq(1).val();
		 var postContent=$(obj).siblings("input").eq(2).val();
		 var gameId=$(obj).siblings("input").eq(3).val();
		 var gameName=$(obj).siblings("input").eq(4).val();
		 var uid=$(obj).siblings("input").eq(5).val();
		 var photo=$(obj).siblings("input").eq(6).val();
		/*  alert(postId+" "+postTitle+" "+postContent+" "+gameId+" "+gameName+" "+uid+" "+photo);  */
		 location.href="chatContent?postId="+postId+"&postTitle="+postTitle+"&postContent="+postContent+"&gameId="+gameId+"&gameName="+gameName+"&uid="+uid+"&photo="+photo;
  }
</script>

</head>
<body>
   <div id="body10">
   <img alt="lol" src="images/1037143.jpg" Style="height:300px;width:100%;">
   <div id="userMessage">
   <img alt="个人图像" :src="user.photo" style="height:100px;width:100px;border:solid 1px pink;">
     <span>姓名：{{user.uname}}</span> 
     <span style="margin-left:120px;">个性签名：{{user.uremake}}</span>   
   </div>
   
   <ul class="layui-nav">
    <li class="layui-nav-item"><a href="html/ChatIndex.jsp">返回首页</a></li>
    <li class="layui-nav-item"><a href="javascript:void(0);" id="mylove">我的关注</a></li>
    <li class="layui-nav-item"><a href="javaScript:void(0);" id="myPost">我的发帖</a></li>
    <li class="layui-nav-item"><a href="javascript:void(0);" id="myReply">我的回复</a></li>
   </ul>
   
   <div id="show">
      <table class="table table-bordered">     
     <tr id="tr" v-if="loveGame != ''"><td>序号</td><td>游戏名称</td><td>修改状态</td></tr>
      <tr v-for=" (ll,index) in loveGame"><td>{{index+1}}</td><td><a :href='"showGameChat?gid=" + ll.gameId'> {{ll.gameName}}</a></td><td><input type="hidden" :value="ll.gameId"><a href="javaScrip:void(0);" class="noLove">取消关注</a></td></tr>     
      </table>  
   </div>
   
   <div id="showMyPost">
   <table class="table table-bordered">
   <tr v-for="cc in chatPost"><td><a href="javascript:void(0);" onclick="showChatContent(this)">{{cc.postTitle}}</a>
   <input type="hidden" id="postId" :value="cc.postId">
   <input type="hidden" id="postTitle" :value="cc.postTitle">
   <input type="hidden" id="postContent" :value="cc.postContent">
   <input type="hidden" id="gameId" :value="cc.game.gameId">
   <input type="hidden" id="gameName" :value="cc.game.gameName">
   <input type="hidden" id="uid" :value="cc.user.uid">
   <input type="hidden" id="photo" :value="cc.user.photo">
   </td>   
   <td>{{cc.postTime}}</td></tr>
   </table>
   <div id="lay"></div>
   </div>   
   
   
    <div id="showReply">
       <table class="table table-bordered" v-for="rr in reply">
       <tr><td><a href="javascript:void(0);" onclick="hh(this)">{{rr.chatPost.postTitle}}</a>
         <input type="hidden" id="postId" :value="rr.chatPost.postId">
   <input type="hidden" id="postTitle" :value="rr.chatPost.postTitle">
   <input type="hidden" id="postContent" :value="rr.chatPost.postContent">
   <input type="hidden" id="gameId" :value="rr.chatPost.game.gameId">
   <input type="hidden" id="gameName" :value="rr.chatPost.game.gameName">
   <input type="hidden" id="uid" :value="rr.chatPost.user_id">
   <input type="hidden" id="photo" :value="rr.chatPost.user.photo">
       </td></tr>
       <tr><td>{{rr.replyTontent}}</td></tr>
       </table>
      <div id="ll"></div>
   </div>
   <script type="text/javascript">
      function showPost(currentPage){    	  
    			 $.ajax({
    				 url:'getUserPost.do',
    				 type:'post',
    				 data:{currentPage:currentPage},
    				 dataType:'json',
    				 success:function(result){
    					 vv.chatPost=result.userChatList;
    					 laypage({
    			    			cont:$("#lay"),
    			    			pages:result.pages, 
    			    			curr:currentPage,
    			    		    groups:3,
    			    		   /*  skin:'molv', */
    							skip:true,
    							jump:function(obj,first){
    								if(!first){
    									showPost(obj.curr);
    								}
    							}
    			    		})
    				 }    			
    			 })   			    		 
      };  
      var vv=new Vue({
    	  el:'#showMyPost',
    	  data:{
    		chatPost:"",  
    	  },
      });
      
      function showReply(currentPage){
    	  $.ajax({
    		  url:'getUserReply.do',
    		  type:'post',
    		  data:{currentPage:currentPage},
    		  dataType:'json',
    		  success:function(result){
    			  uu.reply=result.userReplyList
    			  laypage({
		    			cont:$("#ll"),
		    			pages:result.pages, 
		    			curr:currentPage,
		    		    groups:3,
		    		   /*  skin:'molv', */
						skip:true,
						jump:function(obj,first){
							if(!first){
								showReply(obj.curr);
							}
						}
		    		})  
    		  }
    	  })
      }
      
      var uu=new Vue({
    	  el:'#showReply',
    	  data:{
    		reply:"",  
    	  },
      })
   </script>
   
  
   </div>
</body>
</html>